﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Csharphomework4_1
{
    class Order : IComparable
    {
        public long orderNumber;
        public string objectName;
        public string customer;
        public int cost;

        public Order(long orderNumber,string objectName,string customer,int cost)
        {
            this.orderNumber = orderNumber;
            this.objectName = objectName;
            this.customer = customer;
            this.cost = cost;
        }

        public int CompareTo(object obj)
        {
            if (!(obj is Order)) throw new ArgumentException();
            Order o2 = (Order)obj;
            return (int)(this.orderNumber - o2.orderNumber);
        }

        public override bool Equals(object obj)
        {
            return obj is Order order &&
                   orderNumber == order.orderNumber &&
                   objectName == order.objectName &&
                   customer == order.customer &&
                   cost == order.cost;
        }

        public override int GetHashCode()
        {
            return HashCode.Combine(orderNumber, objectName, customer, cost);
        }

        public override string ToString()
        {
            return (orderNumber+"   "+objectName+ "   "+customer + "   "+cost);
        }
    }
}

